<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="用户ID" prop="accountId">
        <el-input
          v-model="queryParams.accountId"
          placeholder="请输入用户ID"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item label="大神等级" prop="godLevel">
        <el-input
          v-model="queryParams.godLevel"
          placeholder="请输入大神等级"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item label="申请品类" prop="teamCategoryItemId">
        <el-select v-model="queryParams.teamCategoryItemId" placeholder="请选择">
          <el-option v-for="item in teamCategoryOptions" :key="item.id" :label="item.name" :value="item.id"/>
        </el-select>
      </el-form-item>
      <el-form-item label="熟练位置" prop="skilledPosition">
        <el-input
          v-model="queryParams.skilledPosition"
          placeholder="请输入熟练位置"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item label="陪玩标签" prop="gatecorys">
        <el-input
          v-model="queryParams.gatecorys"
          placeholder="请输入陪玩标签"
          clearable
          size="small"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>

    <p>
      <el-radio-group v-model="queryParams.status" @change="getList">
        <el-radio-button :label="1">待审核</el-radio-button>
        <el-radio-button :label="0">已通过</el-radio-button>
        <el-radio-button :label="2">未通过</el-radio-button>
      </el-radio-group>
    </p>

    <el-table v-loading="loading" :data="userManitoApplyList" >
      <el-table-column label="用户ID" align="center" prop="accountId" width="150px"/>
      <el-table-column label="用户昵称" align="center" prop="userNike" />
      <el-table-column label="大神等级" align="center" prop="godLevel" />
      <el-table-column label="申请品类" align="center" prop="gategoryName" />
      <el-table-column label="平台大区" align="center" prop="regionName" />
      <el-table-column label="最高实力" align="center" prop="highestStrengthName" :show-overflow-tooltip="true"/>

      <el-table-column label="熟练位置" align="center" prop="skilledPosition" :show-overflow-tooltip="true"/>
      <el-table-column label="擅长英雄" align="center" prop="skilledRole" />
      <el-table-column label="最高实力截图" align="center" prop="highestStrengthScreenshot" width="150px" :show-overflow-tooltip="true"/>
      <el-table-column label="形象照片" align="center" prop="image" />
      <el-table-column label="实力展示" align="center" prop="strengthDisplay" :show-overflow-tooltip="true"/>
      <el-table-column label="视频展示" align="center" prop="vedioDisplay" :show-overflow-tooltip="true"/>
      <el-table-column label="陪玩标签" align="center" prop="gatecorys" :show-overflow-tooltip="true"/>
      <el-table-column label="语音介绍" align="center" prop="phoneticsIntroduction" :show-overflow-tooltip="true"/>
      <el-table-column label="个人简介" align="center" prop="personIntroduction" :show-overflow-tooltip="true"/>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <span v-if="scope.row.status === 1">待审核</span>
          <span v-else-if="scope.row.status === 0">审核通过</span>
          <span v-else-if="scope.row.status === 2">审核未通过</span>
          <span v-else>审核未通过</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
          >审核</el-button>
          <!-- <el-button
            size="mini"
            type="text"
            @click="showInfo(scope.row)"
          >详情</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改大神申请审核对话框 -->
    <el-dialog title="大神审核" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请用户" >
          {{form.userNike}}
        </el-form-item>
        <el-form-item label="大神审核" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio :label="0">审核通过</el-radio>
            <el-radio :label="2">审核不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="原因" prop="appylyText">
          <el-input type="textarea" v-model="form.appylyText" :rows="3"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- <el-dialog title="大神详情" :visible.sync="open" width="50%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="申请用户" >
          {{form.userNike}}
        </el-form-item>
        <el-form-item label="申请用户" >
          {{form.userNike}}
        </el-form-item>
        <el-form-item label="大神审核" prop="status">
          <el-radio-group v-model="form.status">
            <el-radio :label="1">审核通过</el-radio>
            <el-radio :label="2">审核不通过</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="原因" prop="appylyText">
          <el-input type="textarea" v-model="form.appylyText" :rows="3"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog> -->

  </div>
</template>

<script>
import { listUserManitoApply, getUserManitoApply, delUserManitoApply, addUserManitoApply, updateUserManitoApply, exportUserManitoApply } from "@/api/system/userManitoApply";
import { loadTeamCategoryItem } from "@/api/system/teamCategoryItem";


export default {
  name: "UserManitoApply",
  data() {
    return {
      teamCategoryOptions: [],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 大神申请审核表格数据
      userManitoApplyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        accountId: undefined,
        godId: undefined,
        godLevel: undefined,
        teamCategoryItemId: undefined,
        regionId: undefined,
        highestStrengthId: undefined,
        skilledPosition: undefined,
        skilledRole: undefined,
        highestStrengthScreenshot: undefined,
        image: undefined,
        strengthDisplay: undefined,
        vedioDisplay: undefined,
        phoneticsIntroduction: undefined,
        personIntroduction: undefined,
        status: 0,
        gatecorys: undefined
      },
      info: {},
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        accountId: [
          { required: true, message: "用户ID不能为空", trigger: "blur" }
        ],
        godLevel: [
          { required: true, message: "大神等级不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "申请时间不能为空", trigger: "blur" }
        ],
        teamCategoryItemId: [
          { required: true, message: "申请品类ID不能为空", trigger: "blur" }
        ],
        regionId: [
          { required: true, message: "平台大区id不能为空", trigger: "blur" }
        ],
        highestStrengthId: [
          { required: true, message: "最高实力id不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
    loadTeamCategoryItem().then(response => {
      this.teamCategoryOptions = response.data;
    });
  },
  methods: {
    /** 查询大神申请审核列表 */
    getList() {
      this.loading = true;
      listUserManitoApply(this.queryParams).then(response => {
        this.userManitoApplyList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        accountId: undefined,
        godId: undefined,
        godLevel: undefined,
        createTime: undefined,
        teamCategoryItemId: undefined,
        regionId: undefined,
        highestStrengthId: undefined,
        skilledPosition: undefined,
        skilledRole: undefined,
        highestStrengthScreenshot: undefined,
        image: undefined,
        strengthDisplay: undefined,
        vedioDisplay: undefined,
        phoneticsIntroduction: undefined,
        personIntroduction: undefined,
        status: "0",
        state: undefined,
        price: undefined,
        gatecorys: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加大神申请审核";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.form = JSON.parse(JSON.stringify(row));
      this.open = true;
      this.title = "修改大神申请审核";
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateUserManitoApply(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addUserManitoApply(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    showInfo(row) {
      this.reset();
      const id = row.id || this.ids
      this.info = JSON.parse(JSON.stringify(row));
    },
  }
};
</script>